package bg.btanev.eightyfour.domain.profile.feed;

import org.apache.commons.lang.Validate;

import bg.btanev.eightyfour.domain.entitybase.DomainValue;

/**
 *
 * @author B.Tanev
 *
 */
public class FeedMediaContent implements DomainValue {
	/**
	 *
	 */
	private static final long serialVersionUID = 1071970478768446816L;

	private String url; //not-null
	private String type; //expected value mime type; not-null

	private FeedMediaContentMeta meta; //component
	private FeedMediaContentDimensions dimensions; //component

	protected FeedMediaContent() {
		super();
	}

	public FeedMediaContent(final String url, final String type) {
		this(url, type, null, null);
	}

	public FeedMediaContent(final String url, final String type, final FeedMediaContentMeta meta,
			final FeedMediaContentDimensions dimensions) {
		this();

		Validate.notEmpty(url);
		Validate.notEmpty(type);

		this.url = url;
		this.type = type;
		this.meta = meta;
		this.dimensions = dimensions;
	}

	public String getUrl() {
		return url;
	}

	public String getType() {
		return type;
	}

	public FeedMediaContentMeta getMeta() {
		return meta;
	}

	public FeedMediaContentDimensions getDimensions() {
		return dimensions;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		result = prime * result + ((url == null) ? 0 : url.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FeedMediaContent other = (FeedMediaContent) obj;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		if (url == null) {
			if (other.url != null)
				return false;
		} else if (!url.equals(other.url))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "FeedMediaContent [meta=" + meta + ", type=" + type + ", url=" + url + ", dimesions=" + dimensions + "]";
	}
}
